import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { request } from 'network/request'
import fastclick from 'fastclick';

import { Swipe, SwipeItem, Toast, Popup, Cell, GoodsAction, GoodsActionIcon, GoodsActionButton, Button, Field, Form, Dialog, Card, Checkbox, SwipeCell, Stepper, Tab, Tabs, Sidebar, SidebarItem, SubmitBar   } from 'vant';

// fastclick解决移动端click300ms延迟问题
fastclick.attach(document.body)
// 网络请求模块
Vue.prototype.$axios = request;
// rem适配
import 'amfe-flexible/index'
// vant组件安装
Vue.use(Swipe).use(SwipeItem).use(Popup).use(Cell).use(GoodsAction).use(GoodsActionIcon).use(GoodsActionButton).use(Button).use(Field).use(Form).use(Dialog).use(Card).use(Checkbox).use(SwipeCell).use(Stepper).use(Tab).use(Tabs).use(Sidebar).use(SidebarItem).use(SubmitBar);
Toast.setDefaultOptions({ duration: 500 });

// 事件总线eventBus
Vue.prototype.$bus = new Vue();
// 过滤器
Vue.filter('showPrice', (price) => {
  return `￥${price.toFixed(2)}`
})

// 重定向
router.beforeEach((to, from, next) => {
  // console.log(to.path);
  if (to.path == '/profile') {
    if (store.state.uid==null) {
      router.push('/login')
    }
  }
  next()
  
})




Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
